<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<title>数据存储</title>
		<link href="../../component/pear/css/pear.css" rel="stylesheet">
	</head>
	<body class="pear-container">
		<div class="layui-row layui-col-space10">
			<div class="layui-col-md6">
				<form class="layui-form" lay-filter="form_config">
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">Redis设置</div>
						<div class="layui-card-body layui-row layui-col-space10">
							<div class="layui-col-md12">
								<div class="layui-form-item">
									<label class="layui-form-label">Redis</label>
									<div class="layui-input-block">
										<input type="checkbox" name="redis" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">开启SSL</label>
									<div class="layui-input-block">
										<input type="checkbox" name="redis_ssl" lay-skin="switch" lay-filter="config_switch_boolean" title="ON|OFF" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">IP地址</label>
									<div class="layui-input-inline">
									<input type="text" name="redis_host" lay-verify="redis" lay-reqtext="IP地址不能为空" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">端口号</label>
									<div class="layui-input-inline">
									<input type="text" name="redis_port" lay-verify="redis|number" lay-reqtext="端口号不能为空" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">密码</label>
									<div class="layui-input-inline">
									<input type="password" name="redis_password" lay-verify="" autocomplete="off" lay-filter="config_input" class="layui-input" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">连接池大小</label>
									<div class="layui-input-inline">
									<input type="text" name="redis_pool_size" lay-verify="redis|number" lay-reqtext="连接池大小不能为空" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
								<div class="layui-input-block">
									<button type="submit" class="pear-btn pear-btn-primary" lay-submit lay-filter="config_save">保存</button>
									<button type="reset" class="pear-btn">重置</button>
								</div>
							</div>
						</div>
					</div>
				</form>
			</div>
			<div class="layui-col-md6">
				<form class="layui-form" lay-filter="form_config">
					<div class="layui-card" lay-filter="component-form-element">
						<div class="layui-card-header">Mysql设置</div>
						<div class="layui-card-body layui-row layui-col-space10">
							<div class="layui-col-md12">
								<div class="layui-form-item">
									<label class="layui-form-label">Mysql</label>
									<div class="layui-input-group">
										<input type="checkbox" name="mysql" lay-skin="switch" lay-filter="config_switch" title="ON|OFF" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">IP地址</label>
									<div class="layui-input-group">
										<input type="text" name="mysql_host" lay-verify="mysql" lay-reqtext="IP地址不能为空" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">端口号</label>
									<div class="layui-input-group">
										<input type="text" name="mysql_port" lay-verify="number" lay-reqtext="端口号不能为空" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">用户名</label>
									<div class="layui-input-group">
										<input type="text" name="mysql_user" lay-verify="mysql" lay-reqtext="用户名不能为空" autocomplete="off" lay-filter="config_input" class="layui-input" />
										<div class="layui-input-suffix">需自行创建database(zhongkui_waf)</div>
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">密码</label>
									<div class="layui-input-group">
										<input type="password" name="mysql_password" lay-verify="mysql" lay-reqtext="密码不能为空" autocomplete="off" lay-filter="config_input" class="layui-input" />
									</div>
								</div>
								<div class="layui-form-item">
									<label class="layui-form-label">连接池大小</label>
									<div class="layui-input-group">
									<input type="text" name="mysql_pool_size" lay-verify="mysql|number" lay-reqtext="连接池大小不能为空" lay-filter="config_input" autocomplete="off" class="layui-input" />
									</div>
								</div>
								<div class="layui-input-block">
									<button type="submit" class="pear-btn pear-btn-primary" lay-submit lay-filter="config_save">保存</button>
									<button type="reset" class="pear-btn">重置</button>
								</div>
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
		<script src="../../component/layui/layui.js"></script>
		<script src="../../component/pear/pear.js"></script>
		<script src="../../js/config.js"></script>
		<script>
			layui.use(['form','jquery'], function() {
				var $ = layui.$;
				var form = layui.form;

				form.verify({
					redis: function(value, elem) {
						var checked = $(":checkbox[name='redis']").is(":checked");
						if (checked) {
							var mysqlUser = $(":text[name='mysql_user']").val();
							var reqtext = $(elem).attr("lay-reqtext");
							if (value == "") {
								return reqtext ? reqtext : '必填项不能为空';
							}
						}
					},
					mysql: function(value, elem) {
						var checked = $(":checkbox[name='mysql']").is(":checked");
						if (checked) {
							var mysqlUser = $(":text[name='mysql_user']").val();
							var reqtext = $(elem).attr("lay-reqtext");
							if (value == "") {
								return reqtext ? reqtext : '必填项不能为空';
							}
						}
					}
				});
			});
		</script>
	</body>
</html>
